#ifndef SHOT_H
#define SHOT_H

#include "port.h"
#include "physics.h"
#include "background.h"

enum ShotType {
    SHOT_GUN = 0,
    SHOT_MISSILE,
    SHOT_LASER,
    SHOT_BLACKHOLE,
    SHOT_CLUSTER,
    SHOT_BADGER,
    SHOT_PLANETMAKER,
    SHOT_CARPET,
    SHOT_PANZERSCHRECK,
    SHOT_BIGBANG,

    SHOT_MAX
};

/**
 * Class for a shot.
 * Different types of shots will interact using different functions.
 * 
 **/
class Shot {
    public:
        // Ask the PhysicsModule nicely,
        // and it'll be kind and give you one of these!
        Gravitated *g;
        DataBank *data;
        BITMAP *pic;
        // Indicates if I want to die. This is so some other module that
        // handles this [dataBank?] can kill it off
        bool killMe;
        ShotType type;

        // Free variables for a shot
        double arg[4];
        bool flag[4];
        int life;

        Shot(DataBank *d, ShotType t, double pos[2], double vel[2]);

        // Testing/reacting to external events
        int (*doIdle)(Shot *shot, double delta);
        void (*doBackgroundCollision)(Background *bg, Shot *shot);
        void (*doPlayerCollision)(Shot *s, Player *p);
        void (*doInteraction)(Shot *s, Player *p);

        /** Returns a picture representation for the weapon */
        BITMAP* getPicture(void) {
            return pic;
        }
};

int doNothing(Shot *s,double delta);
void doIdleInteraction(Shot *s, Player *p);

// Various shot types
namespace Gun {
    void doBackgroundCollision(Background *bg, Shot *shot);
    void doPlayerCollision(Shot *s, Player *p);
};

namespace Missile {
    void doBackgroundCollision(Background *bg, Shot *shot);
    void doPlayerCollision(Shot *s, Player *p);
};

namespace Laser {
    void doBackgroundCollision(Background *bg, Shot *shot);
    void doPlayerCollision(Shot *s, Player *p);
    int doIdle(Shot *shot, double delta);
};

namespace Cluster {
    void doBackgroundCollision(Background *bg, Shot *shot);
    void doPlayerCollision(Shot *s, Player *p);
};

namespace BlackHole {
    void doBackgroundCollision(Background *bg, Shot *shot);
    void doPlayerCollision(Shot *s, Player *p);
};

namespace Badger {
    void doBackgroundCollision(Background *bg, Shot *shot);
    void doPlayerCollision(Shot *s, Player *p);
    int doIdle(Shot *shot, double delta);
};

namespace PlanetMaker {
    void doBackgroundCollision(Background *bg, Shot *shot);
    void doPlayerCollision(Shot *s, Player *p);
    int doIdle(Shot *shot, double delta);
    void doInteraction(Shot *s, Player *p);
};

namespace Carpet {
    void doBackgroundCollision(Background *bg, Shot *shot);
    void doPlayerCollision(Shot *s, Player *p);
    int doIdle(Shot *shot, double delta);
};

namespace Panzerschreck {
    void doBackgroundCollision(Background *bg, Shot *shot);
    void doPlayerCollision(Shot *s, Player *p);
    int doIdle(Shot *shot, double delta);
};

namespace BigBang {
    void doBackgroundCollision(Background *bg, Shot *shot);
    void doPlayerCollision(Shot *s, Player *p);
    int doIdle(Shot *shot, double delta);
};

#endif
